import logging
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import Dict, Optional

logger = logging.getLogger(__name__)

class Settings(BaseSettings):
    model_config = SettingsConfigDict(
        env_file=".env",
        env_file_encoding='utf-8',
        extra="ignore"
    )

    APP_NAME: str = "easemate-2api"
    APP_VERSION: str = "20.0.0-final"
    DESCRIPTION: str = (
        "一个将 easemate.ai 转换为兼容 OpenAI 格式 API 的高性能、无头稳定版代理。"
        "注意：easemate.ai 存在高级环境检测 (如 TLS/JA3 指纹)，可能导致在非浏览器环境中"
        "即使签名完全正确也无法通过验证 (返回 Error sign)。"
    )

    API_MASTER_KEY: Optional[str] = None
    NGINX_PORT: int = 8089
    API_REQUEST_TIMEOUT: int = 180

    EASEMATE_DEVICE_UUID: str

    MODEL_MAP: Dict[str, int] = {
        "meta-llama-3.1": 1, "claude-3-haiku": 2, "gpt-4o-mini": 3,
        "deepseek-v2": 4, "deepseek-coder-r1": 5, "gemini-1.5-flash": 6,
        "gemini-1.5-pro": 7, "moonshot-v1": 10, "qwen2-72b-instruct": 11,
    }

settings = Settings()
